<script>
    $().ready(function(){
        $('select[name=txt_active]').change(function(){
            var active = $(this).val();
             var id = $(this).attr('id');             
             $.ajax({
                type : "GET",
                dataType : "json",
                url : "<?php echo base_url().'admin/category/change_update_active'?>",
                data : 'id=' + id + '&active=' + active,
                success : function(result){
                    alert(result.error);
                    return false;
                }
            });
        });        
    });
</script>
<div class="info">
<h1 class="font_h1">Danh sách danh mục</h1>
<?php if(isset($error))  : ?>
<h2 class="error_red"><?php echo $error;?></h2>
<?php endif;?>
<table cellpadding="0" cellspacing="0" style="background:#FFF; color:#000; ">
        <tr class="tr">
        	<td><input type="checkbox" value="" name="check_item" id="check_item" /></td>
            <td>Tên</td>
            <td>Sắp xếp</td>
            <td>URL</td>  
            <td>Parent</td>    
            <td>Kích hoạt</td>           
            <td colspan="2">Action</td>            
        </tr>
        
        <?php
		
			foreach($list_cats as $row){
		?>
        	<tr style="text-align:center">
            	<td><input type="checkbox" value="<?php echo $row->id_cats;?>" /></td>
            	
                <td><?php echo $row->name_cats;?></td>
                <td><?php echo $row->order_cats;?></td>
                <td><?php echo $row->url;?></td>
                <td><?php echo $this->category_model->get_name_parent_id($row->id_parent);?></td>
                <td><select name="txt_active" id="<?php echo $row->id_cats;?>" style="width:120px">
            	<option value="1"<?php if($row->active == '1') echo "selected";?>>Hiển thị</option>
                <option value="0"<?php if($row->active == '0') echo "selected";?> >Không hiện thị</option>
               </select></td>
               <td>
            	<a href="<?php echo base_url().'admin/category/add_update/'.$row->id_cats?>" title="Edit"><img src="<?php echo base_url()?>public/admin/images/user_edit.png"></a>&nbsp;&nbsp;&nbsp;<a href="<?php echo base_url().'admin/category/delete_cats/'.$row->id_cats?>" title="Delete"><img src="<?php echo base_url()?>public/admin/images/trash.png"></a>
            </td>
               
               
            </tr>
        <?php } ?>
</table>

<table class="phantrang">
    <tr>
        <td><?php echo $page;?></td>
    </tr>
</table>  
<a href="" class="button">Xóa bản tin đã chọn</a>
<a href="<?php echo base_url()?>admin/category/add_update" class="button">Tạo mới</a>     
</div> 
